package com.mashibing.net.nettycodec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageCodec;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * @description:
 * @author: 余希瑶
 * @date: 2021年06月26日 13:10
 * @version:1.0
 */
public class TankMsgDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        if(byteBuf.readableBytes()<8){
            return;
        }
        int x = byteBuf.readInt();
        int y = byteBuf.readInt();

        list.add(new TankMsg(x,y));

    }
}
